package j05zuoye;

import java.util.HashMap;
import java.util.Map;

class RaceInfo{
    String name;
    int year;
    String addr;
    String winner;

    public RaceInfo(String name, int year, String addr, String winner) {
        this.name = name;
        this.year = year;
        this.addr = addr;
        this.winner = winner;
    }

    @Override
    public String toString() {
        return "RaceInfo{" +
                "name='" + name + '\'' +
                ", year=" + year +
                ", addr='" + addr + '\'' +
                ", winner='" + winner + '\'' +
                '}';
    }
}

public class J4word {
    public static void main(String[] args) {
        Map<Integer,RaceInfo> m = new HashMap<>();
        m.put(1930,new RaceInfo("第一届",1930,"乌拉圭","乌拉圭"));
        m.put(1934,new RaceInfo("第二届",1934,"意大利","意大利"));
        m.put(1938,new RaceInfo("第三届",1938,"法国","意大利"));
        m.put(1950,new RaceInfo("第四届",1950,"巴西","乌拉圭"));
        m.put(1954,new RaceInfo("第五届",1954,"瑞士","西德"));
        m.put(1958,new RaceInfo("第六届",1958,"雅典","巴西"));
        m.put(1962,new RaceInfo("第七届",1962,"智利","巴西"));
        m.put(1966,new RaceInfo("第八届",1966,"英格兰","英格兰"));
        m.put(1970,new RaceInfo("第九届",1970,"墨西哥","巴西"));
        m.put(1974,new RaceInfo("第十届",1974,"前西德","西德"));
        m.put(1978,new RaceInfo("第十一届",1978,"阿根廷","阿根廷"));
        m.put(1982,new RaceInfo("第十二届",1982,"西班牙","意大利"));
        m.put(1986,new RaceInfo("第十三届",1986,"墨西哥","阿根廷"));
        m.put(1990,new RaceInfo("第十四届",1990,"意大利","西德"));
        m.put(1994,new RaceInfo("第十五届",1994,"美国","巴西"));
        m.put(1998,new RaceInfo("第十六届",1998,"法国","法国"));
        m.put(2002,new RaceInfo("第十七届",2002,"韩日","巴西"));
        m.put(2006,new RaceInfo("第十八届",2006,"德国","意大利"));
        m.put(2010,new RaceInfo("第十九届",2010,"南非","西班牙"));
        m.put(2014,new RaceInfo("第二十届",2014,"巴西","德国"));
        m.put(2018,new RaceInfo("第二十一届",2018,"俄罗斯","法国"));
//        System.out.println("m = " + m);
        int year = 200;
        year = 2014;
        RaceInfo raceInfo = m.get(year);
        if(raceInfo==null){
            System.out.println(year+"没有举办");
        }else{
            System.out.println(raceInfo);
        }
        System.out.println("======");
        String name = "巴西";
        System.out.print("[");
        m.values().stream().filter(el->el.winner.equals(name)).forEach(el-> {
            System.out.print(el.year+"\t");
        });
        System.out.println("]");

    }
}
